//
//  MapVC2.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/6/17.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "MapVC2.h"

@interface MapVC2 ()
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@end

@implementation MapVC2

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    BdTV *titleV = [BdTV creatInstanceWithTitle:@"楼盘地图"];
    [titleV.backBtn setTag:11];
    [titleV.backBtn addTarget:self action:@selector(btnOnclick:) forControlEvents:UIControlEventTouchUpInside];
    [[titleV doneBtn] removeFromSuperview];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:titleV];
    
    
    
    
}

-(void)setData:(CustomAnnotation *)data
{
    self.mapView.mapType = MKMapTypeStandard;
    self.mapView.zoomEnabled=true;
    
    
    MKCoordinateRegion region;
    region.center.latitude = data.coordinate.latitude;
    region.center.longitude = data.coordinate.longitude;
    
    
    
    region.span.latitudeDelta = 0.1;
    region.span.longitudeDelta = 0.1;
    region = [self.mapView regionThatFits:region];
    [self.mapView setRegion:region animated:TRUE];
    
    
    [self.mapView addAnnotation:data];
    [self.mapView selectAnnotation:data animated:YES];
    [self.mapView setCenterCoordinate:data.coordinate animated:YES];
}

-(void)btnOnclick:(UIButton*)sender{
    [super btnOnclick:sender];
    
    if (sender.tag==11) {
        [self.navigationController popViewControllerAnimated:YES];
    }
    
}

@end
